﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace CPPEI.Coolzon.Theme.Fashion.MainViewControl
{
    public partial class ZoomView
    {
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                Point pos = System.Windows.Input.Mouse.GetPosition(this);
                if (pos.X > this.canvas.ActualWidth)
                {
                    return;
                }

                if (_eventType == UIEventType.None && _eventState == UIEventState.None)
                {
                    _eventType = UIEventType.Mouse;
                    _eventState = UIEventState.Down;

                    _mousePos = pos;
                    Down(pos);
                }
            }
            base.OnPreviewMouseDown(e);
        }

        protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                Point pos = System.Windows.Input.Mouse.GetPosition(this);
                if (pos.X > this.canvas.ActualWidth)
                {
                    return;
                }
                if (_eventType == UIEventType.Mouse && _eventState == UIEventState.Down)
                {
                    Up(pos);

                    _eventType = UIEventType.None;
                    _eventState = UIEventState.None;
                }
            }
            base.OnPreviewMouseUp(e);
        }

        protected override void OnPreviewMouseMove(MouseEventArgs e)
        {
            if (_eventType == UIEventType.Mouse && _eventState == UIEventState.Down)
            {
                Point pos = System.Windows.Input.Mouse.GetPosition(this);
                if (pos.X > this.canvas.ActualWidth)
                {
                    return;
                }
                Move(pos);
            }
            base.OnPreviewMouseMove(e);
        }
    }
}
